<?php

/*

Get Starter Kit (get_starter.php)

*/

$page_title = "Get Starter Kit";
$rank_check = 1;
include "header.inc.php";

print "$openHTML";

$findGotten = fetch("SELECT * FROM starter_packs_gotten WHERE userid = '$userid' AND game = '$game'");
$findKit = fetch("SELECT * FROM starter_items WHERE game = '$game'");
if (($findGotten[id]) OR (!$findKit[id]))
{
	print "<p align=center>There is something preventing you from getting this kit, either the kits have not been setup for this game or you have already gotten your kit. <a href=myitems.php?game=$game>Back to my items.</a></p>";
}
else
{
	$getI1 = fetch("SELECT * FROM items2 WHERE id = '$findKit[item_1]' AND game = '$game'");
	$getI2 = fetch("SELECT * FROM items2 WHERE id = '$findKit[item_2]' AND game = '$game'");
	$getI3 = fetch("SELECT * FROM items2 WHERE id = '$findKit[item_3]' AND game = '$game'");
	$getI4 = fetch("SELECT * FROM items2 WHERE id = '$findKit[item_4]' AND game = '$game'");
	$getI5 = fetch("SELECT * FROM items2 WHERE id = '$findKit[item_5]' AND game = '$game'");
	if ($getI1[id])
	{
		$showImages .= "<img src=$base_url/images/user_images/opg_$game/items/item_$getI1[id].gif>";
		mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES 	('$userid','$getI1[id]','$getI1[parts]','$game')");
	}
	if ($getI2[id])
	{
		$showImages .= "<img src=$base_url/images/user_images/opg_$game/items/item_$getI2[id].gif>";
		mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES 	('$userid','$getI2[id]','$getI2[parts]','$game')");
	}
	if ($getI3[id])
	{
		$showImages .= "<img src=$base_url/images/user_images/opg_$game/items/item_$getI3[id].gif>";
		mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES 	('$userid','$getI3[id]','$getI3[parts]','$game')");
	}
	if ($getI4[id])
	{
		$showImages .= "<img src=$base_url/images/user_images/opg_$game/items/item_$getI4[id].gif>";
		mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES 	('$userid','$getI4[id]','$getI4[parts]','$game')");
	}
	if ($getI5[id])
	{
		$showImages .= "<img src=$base_url/images/user_images/opg_$game/items/item_$getI5[id].gif>";
		mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES 	('$userid','$getI5[id]','$getI5[parts]','$game')");
	}



	print "<p align=center>Your starter kit has been given to you! You have received the following items:</p>

<p align=center>$showImages</p>

<p align=center><a href=myitems.php?game=$game>Back to my items!</a></p>
";

mysql_query("INSERT INTO starter_packs_gotten (userid,game) VALUES ('$userid','$game')");
}

print "$closeHTML";
?>